The module have some coding standards and best practices issues.

Issue fork addtoany-3329621

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Raghavendra A M created an issue. See original summary.

irfan.gul made their first commit to this issue’s fork.

irfan.gul’s picture

Assigned: Unassigned » irfan.gul
arti_parmar’s picture

Assigned: irfan.gul » arti_parmar

irfan.gul’s picture

I am a beginner contributor, I tried to fix some coding standard issues in the module.

harshitthakore’s picture

Initial review, Here is the list of issues.

FILE: /var/www/html/repos/addtoany/src/Plugin/Block/AddToAnyBlock.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------
64 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
145 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------

harshitthakore’s picture

All Errors are fixed and only few warnings are remaining.

FILE: addtoany/src/Form/AddToAnySettingsForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
----------------------------------------------------------------------
 55 | WARNING | Line exceeds 120 characters; contains 196 characters
 104 | WARNING | Line exceeds 120 characters; contains 142 characters
 149 | WARNING | Line exceeds 120 characters; contains 437 characters
 206 | WARNING | Line exceeds 120 characters; contains 196 characters
 213 | WARNING | Line exceeds 120 characters; contains 189 characters
 238 | WARNING | Line exceeds 120 characters; contains 166 characters
----------------------------------------------------------------------
harshitthakore’s picture

Assigned: arti_parmar » Unassigned
Status: Active » Needs review
harshitthakore’s picture

Issue tags: +Phpcs Drupal coding standard issue

VladimirAus made their first commit to this issue’s fork.

vladimiraus’s picture

Status: Needs review » Needs work

Applied auto fixes and still getting the following errors


FILE: /Users/tesboss/_PROJECTS/drupal/addtoany/addtoany.api.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 14 | ERROR | Type hint "array" missing for $types
----------------------------------------------------------------------


FILE: /Users/tesboss/_PROJECTS/drupal/addtoany/addtoany.module
---------------------------------------------------------------------------------------------------------------------------
FOUND 22 ERRORS AND 3 WARNINGS AFFECTING 19 LINES
---------------------------------------------------------------------------------------------------------------------------
 18 | ERROR | [x] Function comment short description must start with exactly one space
 20 | ERROR | [x] Expected 1 space before opening brace; found 0
 21 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 22 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
 23 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 24 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 25 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 27 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 28 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 29 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 29 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
 30 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 31 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 32 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 32 | WARNING | [ ] Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
 32 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
 32 | ERROR | [x] Concat operator must be surrounded by a single space
 33 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 34 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 35 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 37 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 38 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
 38 | ERROR | [x] Closing brace indented incorrectly; expected 0 spaces, found 1
 38 | ERROR | [x] Expected 1 blank line after function; 2 found
 165 | ERROR | [ ] String concat is not required here; use a single string instead
---------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 21 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------


FILE: /Users/tesboss/_PROJECTS/drupal/addtoany/src/Form/AddToAnySettingsForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 4 WARNINGS AFFECTING 4 LINES
------------------------------------------------------------------------------------------------------------------------------------------
 239 | WARNING | Line exceeds 80 characters; contains 86 characters
 262 | WARNING | Line exceeds 80 characters; contains 98 characters
 265 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 265 | WARNING | Only string literals should be passed to t() where possible
 323 | ERROR | Description for the @return value is missing
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/tesboss/_PROJECTS/drupal/addtoany/src/Plugin/views/field/NodeAddToAnyShare.php
-------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------
 17 | ERROR | Missing short description in doc comment
 24 | ERROR | Missing short description in doc comment
-------------------------------------------------------------------------------------------


FILE: /Users/tesboss/_PROJECTS/drupal/addtoany/src/Plugin/Block/AddToAnyBlock.php
------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------
 24 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 26 | WARNING | Node::load calls should be avoided in classes, use dependency injection instead
 47 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------

Time: 436ms; Memory: 12MB


spriya2896’s picture

Assigned: Unassigned » spriya2896
Issue tags: -

I will work on this issue.

spriya2896’s picture

Assigned: spriya2896 » Unassigned
Status: Needs work » Needs review

I have fixed the issues mentioned in #12. Please review

vladimiraus’s picture

Status: Needs review » Needs work

Please reroll MR.

harshitthakore’s picture

Noticed existing code got change with new methods and approach in base branch. So as of now updated issue branch with base branch code only and we can move forward. Also fixed few code standard issues.

harshitthakore’s picture

Status: Needs work » Needs review
riddhi.addweb’s picture

Status: Needs review » Needs work

Please review the Patch it is failing, When I applied the Patch it failed in the 9.5x version. Let me know if I can test this in any different version.

Checking patch addtoany.libraries.yml...
Checking patch addtoany.module...
error: while searching for:
 * Handle AddToAny integration.
 */

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Render\Markup;
use Drupal\Core\Url;
use Drupal\Component\Utility\UrlHelper;
use Drupal\node\Entity\Node;
use Drupal\addtoany\Form\AddToAnySettingsForm;

/**
 * Implements hook_help().

error: patch failed: addtoany.module:5
error: addtoany.module: patch does not apply
Checking patch js/addtoany.admin.js...
error: while searching for:
(function ($) {
 'use strict';
 Drupal.behaviors.addtoany = {
 attach: function (context, settings) {

 // Initial page setup

 var addtoany_icon = $('input[name="addtoany_universal_button"]').next('label').find('img:first');
 var initial_icon_size_int = parseInt($('input[name="addtoany_buttons_size"]').val());

 // Set the A2A icon's size to match selected Icon Size
 addtoany_icon.height(initial_icon_size_int).width(initial_icon_size_int);

 // Bring attention to large A2A icon option
 // because the universal button will likely be changed to match the other icons
 // (Drupal #states can't handle this)
 $('input[name="addtoany_buttons_size"]').change(function () {

 var icon_size = $(this).val();
 var icon_size_int = parseInt(icon_size);

 // Set the A2A icon's size to match selected Icon Size
 addtoany_icon.height(icon_size_int).width(icon_size_int);

 });

 }
 };

}(jQuery));

error: patch failed: js/addtoany.admin.js:1
error: js/addtoany.admin.js: patch does not apply
Checking patch js/addtoany.js...
Checking patch src/Form/AddToAnySettingsForm.php...
error: while searching for:
 * @param \Drupal\Core\Extension\ExtensionList $module_extension_list
 * The module extension list service.
 * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
 * The entity type bundle info service.
 */
 public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, ExtensionList $module_extension_list, EntityTypeBundleInfoInterface $entity_type_bundle_info) {
 parent::__construct($config_factory);

error: patch failed: src/Form/AddToAnySettingsForm.php:48
error: src/Form/AddToAnySettingsForm.php: patch does not apply
Checking patch src/Plugin/Block/AddToAnyBlock.php...
error: while searching for:

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeInterface;

/**
 * Provides an 'AddToAny share' block.

error: patch failed: src/Plugin/Block/AddToAnyBlock.php:4
error: src/Plugin/Block/AddToAnyBlock.php: patch does not apply
Checking patch src/Plugin/Block/AddToAnyFollowBlock.php...
error: src/Plugin/Block/AddToAnyFollowBlock.php: No such file or directory
Checking patch src/Plugin/views/field/NodeAddToAnyShare.php...

shivamitakari made their first commit to this issue’s fork.

shivamitakari’s picture

Assigned: Unassigned » shivamitakari
shivamitakari’s picture

Issue tags: +dcp2024
shivamitakari’s picture

Status: Needs work » Needs review
damienmckenna’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Reviewed & tested by the community

I can confirm that MR 3329621-fix-coding-standards-2.x solves some coding errors I was setting in 2.0.11, thank you.

damienmckenna’s picture

Assigned: shivamitakari » Unassigned